import Cookies from 'js-cookie';

const user = {
    state: {},
    mutations: {
        logout(state, vm) {
            Cookies.remove('satoken');
            //
            // // 恢复默认样式
            // let themeLink = document.querySelector('link[name="theme"]');
            // themeLink.setAttribute('href', '');
            // 清空打开的页面等数据，但是保存主题数据
            let theme = '';
            if (window.$localStorage.getItem("theme")) {
                theme = window.$localStorage.getItem("theme");
            }
            window.$localStorage.removeItem('name');
            window.$localStorage.removeItem('userId');
            window.$localStorage.removeItem('areaCode');
            window.$localStorage.removeItem('saToken');
            console.log(window.$localStorage.getItem("saToken"))
            if (theme) {
                window.$localStorage.setItem("theme");
            }
        }
    }
};

export default user;
